/**
 * Copyright (c) 2017,安徽皖通科技股份有限公司 All rights reserved.
 * @data:2017年10月16日
 * @author:MaShibo
 */
package com.wttech.dzzf.process.dao;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

import com.wtkj.dao.impl.BaseDataTemplate;
import com.wtkj.dao.impl.ListResultSetExtractor;
import com.wtkj.vo.dzzf.base.kfwd.FundAccount;

/**
 * 资金账户处理DAO
 * 
 * @date 2017年10月16日
 * @author MaShibo
 */
@Repository
public class FundAccountInfoDao extends BaseDataTemplate {
    
    
    @Resource(name = "dzzfJdbcTemplate")
    private JdbcTemplate dzzfJdbcTemplate;
    
    @Resource(name = "jdbcTemplate")
    private JdbcTemplate testJdbcTemplate;
    
    /**
     * 查询正常资金账户数量
     * 
     * @return
     */
    public Integer queryNormalFundAccountNum() {
        final String sql = "SELECT COUNT(1) FROM AC_FUNDACCOUNT A WHERE A.ACCOUNTSTATUS = 1 ";
        return testJdbcTemplate.queryForObject(sql, Integer.class);
    }
    
    /**
     * 分页查询正常资金账户信息
     * 
     * @param startRow
     *            起始行号
     * @param endRow
     *            结束行号
     * @return 资金账户信息
     */
    @SuppressWarnings("unchecked")
    public List<FundAccount> queryNormalFundAccount(int startRow, int endRow) {
        StringBuilder sql = new StringBuilder();
        sql.append(" SELECT * ");
        sql.append("   FROM (SELECT A.*, ROWNUM AS RM ");
        sql.append("           FROM AC_FUNDACCOUNT A ");
        sql.append("          WHERE A.ACCOUNTSTATUS = 1) ");
        sql.append("  WHERE RM >= ? ");
        sql.append("    AND RM <= ? ");
        return (List<FundAccount>) testJdbcTemplate.query(sql.toString(), new Object[] { startRow, endRow },
                new ListResultSetExtractor(new FundAccount()));
    }
    
}
